/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.erp.client.widget;

import com.erp.client.DAO.ServerUserBase;
import com.erp.client.DAO.ServerUserBaseAsync;
import com.erp.client.DAO.ServerUserBaseGetService;
import com.erp.client.DAO.UserBaseInf;
import com.erp.client.DAO.UserPasswordChange;
import com.erp.client.MessAge.myMessage;
import com.erp.client.MessAge.myMesswindow;
import com.erp.client.systemEntryPoint;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.data.BaseListLoader;
import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.data.BeanModelLookup;
import com.extjs.gxt.ui.client.data.BeanModelReader;
import com.extjs.gxt.ui.client.data.RpcProxy;
import com.extjs.gxt.ui.client.event.ComponentEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Administrator
 */
public class myFileDownDialog extends Dialog {

    private myMessage mess = new myMessage();
    private myMesswindow messdisp = new myMesswindow();
    UserPasswordChange userpasswordchange = new UserPasswordChange();
    private ServerUserBaseAsync service;
    private BaseListLoader loader;
    private ListStore<BeanModel> store;
    private Grid<BeanModel> Filegrid;

    public myFileDownDialog() {
        final Window w = new Window();

        //w.setMinimizable(false);
        //w.setMaximizable(false);
        //w.setResizable(false);
        w.setIconStyle("bogus");
        w.setPlain(true);
        w.setSize(420, 350);
        w.setHeading(" ：文件查询");
        w.setLayout(new FitLayout());

        final FormPanel panel = new FormPanel();
        panel.setBorders(false);
        panel.setBodyBorder(false);
        //panel.setSize(500, 400);
        panel.setLabelWidth(100);
        //panel.setPadding(5);
        panel.setHeaderVisible(false);

        service = (ServerUserBaseAsync) GWT.create(ServerUserBase.class);
        ServiceDefTarget endpoint = (ServiceDefTarget) service;
        String moduleRelativeURL = GWT.getModuleBaseURL() + "dao/serveruserbase";
        endpoint.setServiceEntryPoint(moduleRelativeURL);

        //System.out.print(StaticEmpID);
        RpcProxy proxy = new RpcProxy() {

            @Override
            public void load(Object loadConfig, AsyncCallback callback) {
                service.getFileByID(systemEntryPoint.StaticEmpID, callback);
            }
        };
        loader = new BaseListLoader(proxy, new BeanModelReader());
        loader.load();
        store = new ListStore<BeanModel>(loader);

        ColumnConfig fileid = new ColumnConfig("fileID", "文件序号", 60);
        ColumnConfig filename = new ColumnConfig("fileName", "文件全名", 100);
        ColumnConfig Myfile = new ColumnConfig("myfile", "文件名", 100);
        ColumnConfig username = new ColumnConfig("userName", "文档所有者", 60);
        ColumnConfig depname = new ColumnConfig("depName", "部门名称", 60);
        ColumnConfig filetype = new ColumnConfig("fileType", "文件类型", 60);
        ColumnConfig recdate = new ColumnConfig("recDate", "上传日期", 100);
        ColumnConfig delflag = new ColumnConfig("delFlag", "删除标志", 60);
        ColumnConfig empid = new ColumnConfig("empId", "记录者ID", 60);
        fileid.setHidden(true);
        empid.setHidden(true);
        filename.setHidden(true);
        delflag.setHidden(true);
        Myfile.setMenuDisabled(true);
        
        filetype.setMenuDisabled(true);
        username.setMenuDisabled(true);
        depname.setMenuDisabled(true);
        recdate.setMenuDisabled(true);
        List<ColumnConfig> config = new ArrayList<ColumnConfig>();
        config.add(fileid);
        config.add(empid);
        config.add(filename);
        config.add(delflag);
        config.add(Myfile);
        config.add(filetype);
        config.add(username);
        config.add(depname);
        config.add(recdate);
        final ColumnModel cm = new ColumnModel(config);
        Filegrid = new Grid<BeanModel>(store, cm);
        //Filegrid.setSize(400, 260);
        Filegrid.setWidth(400);
        Filegrid.setBorders(true);
        Filegrid.setAutoExpandColumn("fileID");


        //Filegrid.reconfigure(store, cm);

        final ContentPanel cp = new ContentPanel();
        cp.setFrame(true);
        cp.setHeading("Local Paging Grid");
        cp.setButtonAlign(HorizontalAlignment.CENTER);
        cp.setHeaderVisible(false);
        cp.setLayout(new FitLayout());

        cp.add(Filegrid);

        w.add(cp);
        w.show();
    }
}
